<template>
  <div class="home">
    <div class="shoplist">
      <h3>首页</h3>
      <input type="text" v-model="news.searchkey"><span @click="search()">搜索</span>
      <div v-show="!isf" class="sch" v-for="(obj,index) in schdata" :key="index+1">
       <img :src="obj.picUrl" alt="">
       <div class="introduce">
         <h4>{{obj.name}}</h4>
         <span>{{obj.minPriceTip}} {{obj.shippingFeeTip}}</span><span>{{obj.deliveryTimeTip}} {{obj.distance}}</span>
       </div>
      </div>

      <div v-show="isf" @click="toDetail(item)" class="shop" v-for="(item,index) in shoplist" :key="index">
        <div class="imgbox">
          <img :src="item.picUrl" alt="">
        </div>
        <div class="text">
          <h4>{{item.name}}</h4>
          <span> ☆ {{item.wmPoiScore/10}} {{item.monthSalesTip}}</span>
          <span>{{item.minPriceTip}} {{item.shippingFeeTip}}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { shop_list ,search} from '../../utils/api'

export default {
  data(){
    return {
      isf:true,
      news:{
        searchkey:''
      },
      shoplist:[],
       schdata:[
        
       ]
    }
  },
  mounted(){
    shop_list().then((res)=>{
      this.shoplist = res.data.list
    })
  },
  methods:{
    toDetail(item){ 
      this.$router.push('/detail/'+item.mtWmPoiId);
    },
    search(){
         search(this.news).then((res)=>{
             this.schdata= res.data.list;
           }) 
           this.isf = !this.isf
      }
  }
}
</script>

<style lang='scss' scoped>
.shoplist{
  margin: 4vw;
  input{
    width: 70vw;
    margin: 0 2vw 2vw 0;
  }
  .sch{
    display: flex;
    img{
      width: 30vw;
      height: 30vw;
      margin-right: 2vw;
    }
    .introduce{
      display: flex;
      flex-direction: column;
      width: 60vw;
      margin-right: 2vw;
    }
  }
  .shop{
    display: flex;
    margin: 4vw 0;
    .imgbox{
      width: 20vw;
      margin-right: 5vw;
      img{
        width: 100%;
        height: 20vw;
      }
    }
    .text{
      font-size: 4vw;
      h4{
        margin-top: 0;
      }
      span{
        display: block;
      }
    }
  }
}
</style>